package sp.dao;

import java.util.List;

public class Page<T> {
    private List<T> list;// 一页数据
    private int pages;  // 总页数
    private int page;   // 页码
    private int rows;   // 一页多少条
    private int total;  // 总记录数
    private int start;  // 起始位置
    public Page(int page, int rows, int total){
        this.page = page;
        this.total = total;
        this.rows = rows;
        // 计算总页数
        pages = total % rows == 0 ? total / rows : total / rows + 1;
        // 计算起始位置
        start = (page - 1) * rows;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }
}
